<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>experimental::make_parallel_group</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Asio">
<link rel="up" href="../reference.html" title="Reference">
<link rel="prev" href="experimental__is_promise_v.html" title="experimental::is_promise_v">
<link rel="next" href="experimental__operator_pipe_.html" title="experimental::operator|">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../asio.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="experimental__is_promise_v.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="experimental__operator_pipe_.html"><img src="../../next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="asio.reference.experimental__make_parallel_group"></a><a class="link" href="experimental__make_parallel_group.html" title="experimental::make_parallel_group">experimental::make_parallel_group</a>
</h3></div></div></div>
<p>
        <a class="indexterm" name="asio.indexterm.experimental__make_parallel_group"></a>
      </p>
<p>
        Create a group of operations that may be launched in parallel.
      </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">typename</span><span class="special">...</span> <span class="identifier">Ops</span><span class="special">&gt;</span>
<span class="identifier">parallel_group</span><span class="special">&lt;</span> <span class="identifier">Ops</span><span class="special">...&gt;</span> <span class="identifier">make_parallel_group</span><span class="special">(</span>
    <span class="identifier">Ops</span><span class="special">...</span> <span class="identifier">ops</span><span class="special">);</span>
</pre>
<p>
        For example:
      </p>
<pre class="programlisting"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">experimental</span><span class="special">::</span><span class="identifier">make_parallel_group</span><span class="special">(</span>
   <span class="special">[&amp;](</span><span class="keyword">auto</span> <span class="identifier">token</span><span class="special">)</span>
   <span class="special">{</span>
     <span class="keyword">return</span> <span class="identifier">in</span><span class="special">.</span><span class="identifier">async_read_some</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">data</span><span class="special">),</span> <span class="identifier">token</span><span class="special">);</span>
   <span class="special">},</span>
   <span class="special">[&amp;](</span><span class="keyword">auto</span> <span class="identifier">token</span><span class="special">)</span>
   <span class="special">{</span>
     <span class="keyword">return</span> <span class="identifier">timer</span><span class="special">.</span><span class="identifier">async_wait</span><span class="special">(</span><span class="identifier">token</span><span class="special">);</span>
   <span class="special">}</span>
 <span class="special">).</span><span class="identifier">async_wait</span><span class="special">(</span>
   <span class="identifier">asio</span><span class="special">::</span><span class="identifier">experimental</span><span class="special">::</span><span class="identifier">wait_for_all</span><span class="special">(),</span>
   <span class="special">[](</span>
       <span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> <span class="number">2</span><span class="special">&gt;</span> <span class="identifier">completion_order</span><span class="special">,</span>
       <span class="identifier">std</span><span class="special">::</span><span class="identifier">error_code</span> <span class="identifier">ec1</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">n1</span><span class="special">,</span>
       <span class="identifier">std</span><span class="special">::</span><span class="identifier">error_code</span> <span class="identifier">ec2</span>
   <span class="special">)</span>
   <span class="special">{</span>
     <span class="keyword">switch</span> <span class="special">(</span><span class="identifier">completion_order</span><span class="special">[</span><span class="number">0</span><span class="special">])</span>
     <span class="special">{</span>
     <span class="keyword">case</span> <span class="number">0</span><span class="special">:</span>
       <span class="special">{</span>
         <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"descriptor finished: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">ec1</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">n1</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
       <span class="special">}</span>
       <span class="keyword">break</span><span class="special">;</span>
     <span class="keyword">case</span> <span class="number">1</span><span class="special">:</span>
       <span class="special">{</span>
         <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"timer finished: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">ec2</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
       <span class="special">}</span>
       <span class="keyword">break</span><span class="special">;</span>
     <span class="special">}</span>
   <span class="special">}</span>
 <span class="special">);</span>
</pre>
<h5>
<a name="asio.reference.experimental__make_parallel_group.h0"></a>
        <span><a name="asio.reference.experimental__make_parallel_group.requirements"></a></span><a class="link" href="experimental__make_parallel_group.html#asio.reference.experimental__make_parallel_group.requirements">Requirements</a>
      </h5>
<p>
        <span class="emphasis"><em>Header: </em></span><code class="literal">asio/experimental/parallel_group.hpp</code>
      </p>
<p>
        <span class="emphasis"><em>Convenience header: </em></span>None
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2003-2022 Christopher M. Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="experimental__is_promise_v.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="experimental__operator_pipe_.html"><img src="../../next.png" alt="Next"></a>
</div>
</body>
</html>
